package com.wx.app.spacewhisper.utils.result;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @param <T> 返回数据
 * @Description 结果实体类 code为状态码、msg为提示信息、data为返回的数据
 */
@ApiModel(value = "返回结果",description = "每个接口都会返回此格式结果")
public class RetResult<T> {

    public int code;

    private String msg;

    @ApiModelProperty(value = "返回数据", allowEmptyValue = true)
    private T data;

    public RetResult<T> setCode(RetCode retCode) {
        this.code = retCode.code;
        return this;
    }

    public int getCode() {
        return code;
    }

    public RetResult<T> setCode(int code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return msg;
    }

    public RetResult<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public T getData() {
        return data;
    }

    public RetResult<T> setData(T data) {
        this.data = data;
        return this;
    }

    @Override
    public String toString() {
        return "RetResult{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
